import sys
import os

os.system('cat /course/cs158/data/classif/test.dat | cut -d " " -f 1 > toClassify.dat')
os.system('time ./classify.sh -r /course/cs158/data/classif/features1.dat vecoutput1.dat /course/cs158/data/classif/training2.dat toClassify.dat CLASSIFIER_OUTPUT.dat')

# Number of docs to be classified:
fout = os.popen('cat CLASSIFIER_OUTPUT.dat | wc -l')
numDocsClassified = int(fout.read().rstrip('\n'))

# Number of docs differing from provided classifications
fout = os.popen("sdiff -B -b -s CLASSIFIER_OUTPUT.dat /course/cs158/data/classif/test.dat | wc -l")
numDocsDiffer = int(fout.read().rstrip('\n'))

print "PERCENTAGE MATCHED = " + str((1.0 - (numDocsDiffer + 0.0)/(numDocsClassified + 0.0)) * 100)